Here is an implementation of the quicksort algorithm in Python:
```
def quicksort(arr):
    if len(arr) <= 1:
        return arr
    pivot = arr[0]
    less = [x for x in arr[1:] if x <= pivot]
    greater = [x for x in arr[1:] if x > pivot]
    return quicksort(less) + [pivot] + quicksort(greater)
```
This is a top-down implementation of the quicksort algorithm, also known as the "Lomuto" partition scheme. Here's a brief explanation of how it works:

1. If the length of the input array is 0 or 1, return the original array (since it is already sorted).
2. Choose the first element of the array as the pivot.
3. Partition the rest of the array into two subarrays: `less` and `greater`. `less` contains all elements that are less than or equal to the pivot, and `greater` contains all elements that are greater than the pivot.
4. Recursively apply the quicksort algorithm to `less` and `greater`.
5. Combine the results of the two recursive calls, with the pivot element in its final position.

Here's an example usage of the function:
```
arr = [5, 2, 8, 3, 1, 6, 4]
arr = quicksort(arr)
print(arr)  # [1, 2, 3, 4, 5, 6, 8]
```
Note that this implementation has a time complexity of O(n log n) on average, but can be O(n^2) in the worst case if the pivot is chosen poorly. To improve the worst-case performance, you can use a more robust pivot selection method, such as the "median of three" method.

Also, it's worth noting that this implementation is not stable, meaning that if there are duplicate elements in the input array, their order may be swapped during the sorting process. If stability is important, you can use a stable sorting algorithm like mergesort or heapsort instead.